#include <stdio.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))

typedef struct 
{
    int money;
    int number;
} point;

point list[100000] = { 0 };

void sort(point *a, int left, int right)
{
    if(left >= right)
    {
        return ;
    }
    int i = left;
    int j = right;
    point key = a[left];
    while(i < j)                          
    {
        //找到右边小于Key的数
        while(i < j && key.money <= a[j].money)
        {
            j--;
        }
        a[i] = a[j];
        //找到左边大于Key的数
        while(i < j && key.money >= a[i].money)
        {
            i++;
        }
        a[j] = a[i];
    }
     
    a[i] = key;
    sort(a, left, i - 1);
    sort(a, i + 1, right);
}

int main(int argc, char const *argv[])
{   
    int y, c, cn, i, j, k, o, i_max = 0, count = 1, l_max, step, l, n_max;
    point *lp = list, ll, lr, zf;
    scanf("%d", &y);
    scanf("%d%d", &c, &cn);
    lp->money = c;
    lp->number = cn;
    lp++;
    while (1)
    {
        scanf("%d%d", &i, &j);
        if (i == -1 && j == -1)
        {
            break;
        }
        lp->money = i;
        lp->number = j;
        lp++;
        count++;
    }
    sort(list, 0, count-1);
    scanf("%d", &o);

    l_max = 0;
    for (l = 1; l < count; l++)
    {
        ll = list[l - 1];
        lr = list[l];
        printf("\n%d %d", ll.money, ll.number);
        printf("\n%d %d", lr.money, lr.number);
        step = (lr.number - ll.number) / (lr.money - ll.money);
        for (i = ll.money, j = ll.number; i < lr.money; i++, j-=step)
        {
            if (i == y)
            {
                zf.money = i;
                zf.number = j;
            }
            
            l_max = max(l_max, (i-c) * j);
        }
    }

    for (i = list[count-1].number, j = list[count-1].money; i > 0; i-=o, j++)
    {
        if (j == y)
        {
            zf.money = j;
            zf.number = i;
        }

        max(l_max, i * (j-c));
    }
    printf("\n%d", l_max);
    printf("\n%d %d", zf.money, zf.number);
    printf("\n%d", -(l_max - (zf.money-c) * zf.number) / zf.number);
    
    return 0;
}
